package com.ophiux.FeverManagement;

import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.encoding.XMLType;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

/**
 * 需要架包  commons-discovery-0.2.jar，jaxrpc.jar,axis.jar
 * @author hhl
 *
 */
public class FeverManagementAxisUtil {
	public static void main(String[] args) {
		micropay();
	}
	
	public static void micropay() {
		String param = "";
		param="{'HEAD':{'TOKEN':'tk2018110815550121','SIGN':'b3BoaXV4X2Nzenh3ekAyMDE4W29iamVjdCBPYmplY3Rd'},'PARAM':{'TITLE':'病解决'}}";
//		invoke(param, "getTreatmentList");
		
		param="{'HEAD':{'TOKEN':'tk2018110815550121','SIGN':'b3BoaXV4X2Nzenh3ekAyMDE4W29iamVjdCBPYmplY3Rd'},'PARAM':{'PATIENT_ID':'1','TREATMENT_ID':'e1d52321eecb4836b47980674c505642','OTHER_ID':'1314','TREATMENT_ADVISE':'多喝水','MEDICINE':[{'MEDICINE_ID':'0d115b75f8dd470088683d94fc6f08ce','MEDICINE_NAME':'枇杷止咳颗粒'},{'MEDICINE_ID':'7a69c23718384988b452516e6ab9163e','MEDICINE_NAME':'999感冒冲剂'}]}}";
//		invoke(param, "addPatientTreatment");
		
		param="{'HEAD':{'TOKEN':'tk2018110815550121','SIGN':'b3BoaXV4X2Nzenh3ekAyMDE4W29iamVjdCBPYmplY3Rd'},'PARAM':{'PATIENT_TREATMENT_ID':'e468f17691fc407f8496f58edde7776a','TREATMENT_ID':'e1d52321eecb4836b47980674c505642','TREATMENT_ADVISE':'多喝水2','MEDICINE':[{'MEDICINE_ID':'0d115b75f8dd470088683d94fc6f08ce','MEDICINE_NAME':'枇杷止咳颗粒1'},{'MEDICINE_ID':'7a69c23718384988b452516e6ab9163e','MEDICINE_NAME':'999感冒冲剂1'}]}}";
//		invoke(param, "editPatientTreatment");
		
		param="{'HEAD':{'TOKEN':'tk2018110815550121','SIGN':'b3BoaXV4X2Nzenh3ekAyMDE4W29iamVjdCBPYmplY3Rd'},'PARAM':{'PATIENT_TREATMENT_ID':'e468f17691fc407f8496f58edde7776a'}}";
//		invoke(param, "delPatientTreatment");
		
		param="{'HEAD':{'TOKEN':'tk2018110815550121','SIGN':'b3BoaXV4X2Nzenh3ekAyMDE4W29iamVjdCBPYmplY3Rd'},'PARAM':{'OTHER_ID':'1314','PATIENT_NAME':'','START_DATE':'','END_DATE':'2019-03-21'}}";
//		invoke(param, "getPatientTreatmentListByDoctor");
		
		param="{'HEAD':{'TOKEN':'tk2018110815550121','SIGN':'b3BoaXV4X2Nzenh3ekAyMDE4W29iamVjdCBPYmplY3Rd'},'PARAM':{'PATIENT_NAME':'何海','TEL':'','ID_NO':'','START_DATE':'','END_DATE':''}}";
		invoke(param, "getPatientTreatmentListByPatient");
		
		
	}
	
	public static String invoke(String param,String method) {
		String result="";
		try {
			String endpoint ="http://127.0.0.1:2058/ws/service?wsdl";
			// 直接引用远程的wsdl文件
			Service service = new Service();
			Call call = (Call) service.createCall();
			call.setTargetEndpointAddress(endpoint);
			QName qname = new QName("http://FeverManagement.ophiux.com/", method);
			call.setOperationName(qname);
			call.addParameter("arg0", XMLType.XSD_STRING, ParameterMode.IN);
			Object[] obj = { param };
			call.setReturnType(XMLType.XSD_STRING);
			result = (String) call.invoke(obj);
			System.out.println(result);
		} catch (Exception e) {
			System.err.println(e.toString());
		}
		return result;
	}
}
